package palmtop.com.palmtop.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

import org.xutils.x;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/1/22.
 */
public class GalleryIndexSecondAdapter extends BaseAdapter{
    ArrayList<String> imagList;
    Context context;
    public GalleryIndexSecondAdapter(ArrayList<String> list, Context cx){
        imagList = list;
        context = cx;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return Integer.MAX_VALUE;
    }

    @Override
    public Object getItem(int arg0) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup arg2) {
        // TODO Auto-generated method stub
        ImageView imageView = new ImageView(context);
        //imageView.setBackgroundResource(imagList.get(position%imagList.size()));
        //imageView.setImageBitmap(imagList.get(position%imagList.size()));
        /*ImageOptions options = new ImageOptions.Builder()
                // 设置加载过程中的图片
                .setLoadingDrawableId(
                        R.mipmap.loading)
                .setUseMemCache(
                        true)
                // 设置显示圆形图片

                // 设置支持gif
                .setIgnoreGif(false)
                .setImageScaleType(ImageView.ScaleType.FIT_XY)
                .setSize(1000,1000)
                .build();*/

        x.image().bind(imageView,imagList.get(position%imagList.size()));
        float h,w;
        h = imageView.getDrawable().getIntrinsicHeight();
        w = imageView.getDrawable().getIntrinsicWidth();
       // imageView.setLayoutParams(new Gallery.LayoutParams((int) (190.0/(h/w)), 190));
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
        imageView.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT, Gallery.LayoutParams.MATCH_PARENT));
        return imageView;

    }
}